package com.zy.edu.bean;

import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.zy.edu.config.SystemParam;
import lombok.Data;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * <p>
 * 
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-08-26
 */
@TableName("course_chapter_homework")
@Data
public class CourseChapterHomework implements Serializable {

    private static final long serialVersionUID = 1L;

    private String id;
    /**
     * 顺序
     */
    private Integer num;
    /**
     * 名称
     */
    @NotBlank(message = "作业名称不能为空;")
    private String name;
    @TableField("class_id")
    private String classId;
    @TableField("course_id")
    private String courseId;
    /**
     * 课时id
     */
    @TableField("chapter_id")
    private String chapterId;
    /**
     * 简介
     */
    private String introduction;
    @TableField("create_time")
    @JSONField(format="yyyy-MM-dd hh:mm:ss")
    private Date createTime;
    /**
     * 作业地址
     */
    private String url;
    /**
     * 1: 课时作业;2 班级作业
     */
    private Integer type;
    /**
     * 状态：1 在用；2 停用
     */
    @JSONField(serialize = false)
    private Integer status;

    //批改作业列表 --- 数据查询时，该作业对应的班级id
    @TableField(exist = false)
    private String hclass;

    public String getClassName(){
        if(!StringUtils.isEmpty(this.hclass)){
            return SystemParam.CLASSINFOS.get(this.hclass);
        }
        return null;
    }

    //批改作业列表 --- 学生已提交的数量
    @TableField(exist = false)
    private Integer countSub;
    //作业总数
    @TableField(exist = false)
    private Integer count;
    //已批改
    @TableField(exist = false)
    private Integer countScore;

    @TableField(exist = false)
    @JSONField(format="yyyy-MM-dd hh:mm:ss")
    private Date htime;
}
